// 基本路由地址
import request from '@/utils/requset.js'
// mock路由地址
import mockRequest from '@/utils/mockRequest.js'

// 获取 分类导航
export const getNavListAPI = () => {
  return request({
    method: 'get',
    url: '/api/product/getBaseCategoryList'
  })
}

// 获取 轮播图照片
export const getBannerListAPI = () => {
  return mockRequest({
    method: 'get',
    url: '/banner'
  })
}

export const getNavListAPI1 = () => {
  return mockRequest({
    method: 'get',
    url: '/homeList'
  })
}

// 获取 小轮播图
export const getFloorListAPI = () => {
  return mockRequest({
    method: 'get',
    url: '/floor'
  })
}

// 获取 搜索列表
export const getSearchListAPI = (data) => {
  return request({ method: 'post', url: '/api/list', data })
}

// 获取 商品详情信息
export const getDetailListAPI = (skuId) => {
  return request({
    method: 'get',
    url: `/api/item/${skuId}`,

  })
}

// 拉起 添加到购物车(对已有物品进行数量改动)
export const postCartListAPI = (skuId, skuNum) => {
  return request({
    method: 'post',
    url: `api/cart/addToCart/${skuId}/${skuNum}`
  })
}

// 获取 购物车列表
export const getCartListAPI = () => {
  return request({
    method: 'get',
    url: 'api/cart/cartList'
  })
}

// 删除 购物车商品
export const deleteCartListAPI = (skuId) => {
  return request({
    method: 'delete',
    url: `/api/cart/deleteCart/${skuId}`
  })
}

// 切换 商品选中状态
export const getCartCheckedAPI = (skuID, isChecked) => {
  return request({
    method: 'get',
    url: `/api/cart/checkCart/${skuID}/${isChecked}`
  })
}

// 登录
export const loginAPI = (data) => {
  return request({
    method: 'post',
    url: '/api/user/passport/login',
    data
  })
}

// 获取 用户信息
export const getUserInfoAPI = () => {
  return request({
    method: 'get',
    url: '/api/user/passport/auth/getUserInfo'
  })
}

// 退出 登录
export const logoutAPI = () => {
  return request({
    method: 'get',
    url: '/api/user/passport/logout'
  })
}

// 获取 验证码
export const getSendCodeAPI = (phone) => {
  return request({
    method: 'get',
    url: `/api/user/passport/sendCode/${phone}`
  })
}

// 注册 用户
export const postUserRegisterAPI = (phone, password, code) => {
  return request({
    method: 'post',
    url: '/api/user/passport/register',
    data: {
      phone,
      password,
      code
    }
  })
}
